<script lang="ts" setup>
  import { House, ArrowRight, List } from "@element-plus/icons-vue"
    import { reactive } from 'vue'
    import { Dept, Vacation } from "../model/index";
    import { onMounted } from "vue";
    import userStore from '../store/UserStore';
    import createAxios from "../request";

let axios = createAxios();
import { ElMessage } from "element-plus";
import { RouterLink } from "vue-router";
let store = userStore();
let s =store.getDeptno;
let data = reactive({
    "deptno":s,
    "sum":0
    });

 
  const getData = function (){
    if (store.getRoot==2) {
        axios({
            url: "/getss",
            method: "POST",
            data:data.deptno
        }).then((res)=>{
            //请求成功
            ElMessage.success("请求成功")
            data.sum = res.data;
        }).catch((err)=>{
            //请求失败·
            ElMessage.error("请求失败")
            console.log(err);
        })
    }
    else if(store.getRoot==3){
      axios({
            url: `/gets`,
            method: "POST",
            data:s
        }).then((res)=>{
            //请求成功
            data.sum = res.data;
        }).catch((err)=>{
            //请求失败·
            console.log(err);
        })
    }
  
  }

    onMounted(() => {
      getData();
    });

  const tableData = [

    {
      "info":'List item 1'
    },
  ]
  
</script>

<template>
  <el-container id="mainView">
    <el-header style="background-color: #272822; color: #E5E5E5; line-height: 60px; font-size: 27px;">首页</el-header>
    <el-footer style="height: 30px; line-height: 30px; background-color: #4E5246; border-bottom:1px solid #7A7A7A; border-top:1px solid #7A7A7A;">
      <el-breadcrumb :separator-icon="ArrowRight" style="line-height: 30px;">
        <el-breadcrumb-item :to="{ path: '/home/homepage' }"><el-icon><House /></el-icon>首页</el-breadcrumb-item>
        <el-breadcrumb-item>首页</el-breadcrumb-item>
      </el-breadcrumb>
    </el-footer>
    <el-main style="padding-bottom: 0%;">
      <span style="color: #E5E5E5; line-height: 30px;">
        <el-icon><List /></el-icon>
        待办事项
        <el-tag size="small">{{ tableData.length }}</el-tag>
      </span>
      <el-table :data="tableData" style="width: 100%" :show-header="false">
        <el-table-column  v-if="store.getRoot==2">
          {{data.sum}}个员工申请补签，请<RouterLink to="/home/approveAttend">点击这里</RouterLink>进行审批 
        </el-table-column>
        <el-table-column  v-if="store.getRoot==3">
          {{data.sum}}个员工申请休假，请<RouterLink to="/home/approveVocation">点击这里</RouterLink>进行审批 
        </el-table-column>
      </el-table>
    </el-main>
  </el-container>
  
</template>
  
<style scoped>
  #mainView{
    height: 100%;
    width: 100%;
  }
</style>
  